package com.bw.tap;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;

import com.bw.lib_core.bean.BaseBean;
import com.bw.lib_core.mvvm.model.BaseModel;
import com.bw.lib_core.mvvm.viewmodel.BaseViewModel;
import com.bw.tap.bean.Community;
import com.bw.tap.bean.CommunityDataBean;

import java.util.List;

public class MainViewModel extends BaseViewModel<MainModel> {


    public MutableLiveData<List<Community>> data = new MutableLiveData<>();

    @Override
    public void create() {
        super.create();
        mModel.requestData1();
        mModel.requestData2();
        mModel.requestData3();
    }

    @Override
    protected void onResult(BaseBean baseBean) {
        if (baseBean instanceof CommunityDataBean) {
            //setValue postValue
            //LiveData 问题数据丢失问题，数据倒灌问题

            //异步数据排序
            //data.postValue(((CommunityDataBean) baseBean).data);
            data.setValue(((CommunityDataBean) baseBean).data);
        }
    }
}
